
################################################
###
### smart module 运行时
###
################################################

from smart_module.module_system.process_animations import processAnimations
from smart_module.module_system.process_dialogs import processDialogs
from smart_module.module_system.process_factions import processFactions
from smart_module.module_system.process_game_menus import processGameMenus
from smart_module.module_system.process_global_variables import processGlobalVariables
from smart_module.module_system.process_global_variables_unused import processGlobalVariablesUnused
from smart_module.module_system.process_info_pages import processInfoPages
from smart_module.module_system.process_init import processInit
from smart_module.module_system.process_items import processItems
from smart_module.module_system.process_map_icons import processMapIcons
from smart_module.module_system.process_meshes import processMeshs
from smart_module.module_system.process_mission_tmps import processMissionTmps
from smart_module.module_system.process_music import processMusic
from smart_module.module_system.process_particle_sys import processParticleSys
from smart_module.module_system.process_parties import processParties
from smart_module.module_system.process_party_tmps import processPartyTmps
from smart_module.module_system.process_postfx import processPostfx
from smart_module.module_system.process_presentations import processPresentations
from smart_module.module_system.process_quests import processQuests
from smart_module.module_system.process_scene_props import processSceneProps
from smart_module.module_system.process_scenes import processScenes
from smart_module.module_system.process_scripts import processScripts
from smart_module.module_system.process_simple_triggers import processSimpleTriggers
from smart_module.module_system.process_skills import processSkills
from smart_module.module_system.process_skins import processSkins
from smart_module.module_system.process_sounds import processSounds
from smart_module.module_system.process_strings import processStrings
from smart_module.module_system.process_tableau_materials import processTableauMaterials
from smart_module.module_system.process_tags_unused import processTagsUnused
from smart_module.module_system.process_troops import processTroops
from smart_module.smart_core.banner_print import BannerPrinter
from smart_module.smart_core.base.executor.smart_module_config_parser import SmartModuleConfigParser
from smart_module.smart_core.process_smart_module import processSmartModule
from smart_module.smart_core.report_smart_module import reportSmartModule
from smart_module.smart_core.smart_modules_log import info


class SmartModuleContext:
    def __init__(self,configParser,bannerPrinter):
        ## 横幅打印器
        self.bannerPrinter = bannerPrinter;
        ## 配置解析器
        self.configParser = configParser;
        ## 当前环境
        self.profile = configParser.getProfile();


class SmartRuntime:

    def __init__(self,config):
        self.config = config;
        ## 全局横幅打印机
        self.bannerPrinter = BannerPrinter()
        ## 全局配置解析器
        self.configParser = SmartModuleConfigParser(config)

    def build(self):
        ## 创建上下文对象
        context = SmartModuleContext(self.configParser,self.bannerPrinter)
        ## 是否跳过原生编译
        skipNative = self.configParser.getSkipNative()

        ## 预先处理SmartModule模块功能
        processSmartModule(context)

        if skipNative == False:
            info("现在开始进行原生系统的编译")
            ## 系统功能模块
            processTagsUnused(context)
            processInit(context)
            processGlobalVariables(context)
            processStrings(context)
            processSkills(context)
            processMusic(context)
            processAnimations(context)
            processMeshs(context)
            processSounds(context)
            processSkins(context)
            processMapIcons(context)
            processFactions(context)
            processItems(context)
            processScenes(context)
            processTroops(context)
            processParticleSys(context)
            processSceneProps(context)
            processTableauMaterials(context)
            processPresentations(context)
            processPartyTmps(context)
            processParties(context)
            processQuests(context)
            processInfoPages(context)
            processScripts(context)
            processMissionTmps(context)
            processSimpleTriggers(context)
            processDialogs(context)
            processGlobalVariablesUnused(context)
            processPostfx(context)
            processGameMenus(context)

        ## 显示概要信息
        bannerPath = self.config.get("bannerPath")
        if bannerPath == None:
            bannerPath = "banner.txt"
        self.bannerPrinter.print(bannerPath,self.config)
        ## 显示报告信息
        reportSmartModule(context)



